In [1]:
import matplotlib.pyplot as plt
import rasterio
from rasterio import plot
In [2]:
src = rasterio.open(r"../tests/data/RGB.byte.tif")
In [3]:
%matplotlib inline
plot.show(src)
Out[3]:
In [4]:
world = rasterio.open(r"../tests/data/world.rgb.tif")
plot.show((world, 2), cmap='viridis')
Out[4]:
In [5]:
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(15,7))
plot.show(src, ax=ax1)
plot.show((world, 2), cmap='viridis', ax=ax2)
fig.tight_layout()
In [6]:
fig, (axr, axg, axb) = plt.subplots(1,3, figsize=(21,7))
plot.show((src, 1), ax=axr, cmap='Reds', title='red channel')
plot.show((src, 2), ax=axg, cmap='Greens', title='green channel')
plot.show((src, 3), ax=axb, cmap='Blues', title='blue channel')
Out[6]:
In [7]:
%matplotlib notebook
fig, (axr, axg, axb) = plt.subplots(1,3, figsize=(12, 4), sharex=True, sharey=True)
plot.show((src, 1), ax=axr, cmap='Reds', title='red channel')
plot.show((src, 2), ax=axg, cmap='Greens', title='green channel')
plot.show((src, 3), ax=axb, cmap='Blues', title='blue channel')
Out[7]:
In [8]:
%matplotlib inline
plot.show_hist(src)
In [9]:
plot.show_hist(world, bins=50, lw=0.0, stacked=False, alpha=0.3,
histtype='stepfilled', title="World Histogram overlaid")
In [10]:
plot.show_hist(world, bins=20, lw=2.0, stacked=True,
alpha=0.8, histtype='step', normed=True,
title="World Histogram stacked")
In [11]:
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(15,7))
plot.show(world, ax=ax1)
plot.show_hist(world, bins=50, lw=0.0, stacked=False, alpha=0.3,
histtype='stepfilled', title="World Histogram")
fig.tight_layout()
In [13]:
fig, ax = plt.subplots(1, figsize=(12, 12))
plot.show((world, 1), cmap='Greys_r', interpolation='none', ax=ax)
ax.set_xlim(-50, 0)
ax.set_ylim(0, 40)
plot.show((world, 1), contour=True, ax=ax)
Out[13]:
In [21]:
%matplotlib notebook
fig, ax = plt.subplots(1, figsize=(12, 12))
plot.show((world, 1), cmap='Greys_r', interpolation='none', ax=ax)
ax.set_xlim(-50, 0)
ax.set_ylim(0, 40)
plot.show((world, 1), contour=True, ax=ax,
levels=[25, 125], colors=['white', 'red'], linewidths=4,
contour_label_kws=dict(fontsize=18, fmt="%1.0f", inline_spacing=15, use_clabeltext=True))
Out[21]:
In [12]:
import cartopy
import cartopy.crs as ccrs
fig = plt.figure(figsize=(20, 12))
ax = plt.axes(projection=ccrs.InterruptedGoodeHomolosine())
ax.set_global()
plot.show(world, origin='upper', transform=ccrs.PlateCarree(), interpolation=None, ax=ax)
ax.coastlines()
ax.add_feature(cartopy.feature.BORDERS)
Out[12]:
In [ ]: